<?php 
$baseDir = dirname(__FILE__) . DIRECTORY_SEPARATOR;
define('BASEDIR', $baseDir);

include 'system/config.php';
include 'system/core/interfaces.php';
include 'system/core/core.php';
include 'system/core/cloud.php';

# Create Instance
$cloud =& CC_Core::get_instance();

/* build url */
$fullUrl = $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];

$fullUrl = str_replace('/index.php','',$fullUrl);

$queryUrl = substr($fullUrl, strlen($siteUrl));

$url = explode('/',$queryUrl);

$url = array_filter($url);

$url = array_values($url);
/* build url */

/* determine module */
$controller = $default_controller;
if(isset($url[0])){
	if(file_exists($modulesDir.'/c.'.$url[0].'.php')){
		$controller = $url[0];
	}
	if($url[0] == $controller){
		unset($url[0]);
		$url = array_values($url);
	}
}
/* determine module */

include $modulesDir.'/c.'.$controller.'.php';

/* determine method */
$method = $default_method;
if(isset($url[0])){

	if(method_exists($controller, $url[0])){
		$method = $url[0];
	}
	
	if($url[0] == $method){
		unset($url[0]);
		$url = array_values($url);
	}
}
/* determine method */

include 'system/startup.php';
$controller = new $controller;

# Call the page
$object = array($controller, $method);

call_user_func_array($object, $url);

?>